<template>
    <div class="container myorder">
        <div class="nav_bar">
            <div class="topTitle">
                <div class="pric" @click="goHome"></div>
                <p>我的订单</p>
            </div>

            <div class="tab_bar">
                <ul>
                    <li :class="Indexof == 0 ? 'con' : ''" @click="Indexof = 0">全部<span>{{num||arryNum}}</span></li>
                    <li :class="Indexof == 1 ? 'con' : ''" @click="Indexof = 1">待付款<span>0</span></li>
                    <li :class="Indexof == 2 ? 'con' : ''" @click="Indexof = 2">交易中<span>{{num}}</span></li>
                    <li :class="Indexof == 3 ? 'con' : ''" @click="Indexof = 3">交易成功<span>{{arryNum}}</span></li>
                </ul>
            </div>
        </div>

        <div class="tables" v-if="shop.length ==0 && serv.length ==0">
            <p><img src="../assets/img/dingdan.png" alt=""></p>
            <div class="fonts">您还没有订单</div>
        </div>

        <div class="niuma"></div>

        <main v-if="shop.length !=0">
            <div class="payment" v-for="(item, index) in shop" :key="index">
                <div class="shopname">{{ item.title }}</div>
                <div class="shopImg">
                    <div class="img">
                        <img src="../assets/img/default_img.jpg" alt="">
                        <div class="pofont">{{ item.categoryName }}</div>
                    </div>
                    <div class="rightFont">
                        <div class="title1">{{ item.gameName }}/{{ item.gameServerName }}</div>
                        <div class="title1">订单编号:{{ item.id }}</div>
                        <div class="title1">订单价格:{{ item.price }}.0元</div>
                    </div>
                </div>

                <div class="yesCar" @click="yesshou(item)">确认收货</div>
            </div>
        </main>
        <main v-if="Indexof == 3">
            <div class="payment" v-for="(item, index) in serv" :key="index">
                <div class="shopname">{{ item.title }}</div>
                <div class="shopImg">
                    <div class="img">
                        <img src="../assets/img/default_img.jpg" alt="">
                        <div class="pofont">{{ item.categoryName }}</div>
                    </div>
                    <div class="rightFont">
                        <div class="title1">{{ item.gameName }}/{{ item.gameServerName }}</div>
                        <div class="title1">订单编号:{{ item.id }}</div>
                        <div class="title1">订单价格:{{ item.price }}.0元</div>
                    </div>
                </div>

                <div class="yesCar">已完成</div>
            </div>
        </main>


    </div>
</template>

<script>
import { getlistData } from "../assets/api/home.js";
export default {
    props: ["shopData"],
    data() {
        return {
            Indexof: 0,
            shop: [],
            //全部数据
            datas:[],
            serv:[],

        };
    },
    methods: {
        goHome() {
            this.$router.push("/buy")
        },
        yesshou(item){
            this.Indexof = 3
            console.log(item);
            this.serv.push(item)
            this.shop.pop()
        },
        getlistDataFun() {
            getlistData().then((data) => {
                this.datas = data.data.Data.hits
                console.log(this.datas);
            })
        },
    },
    created() {
        this.getlistDataFun()

        this.shop = this.shopData
        // console.log(this.shop);
    },
    computed: {
        "num"(){
            return this.shop.length
        },
        "arryNum"(){
            return this.serv.length
        }
    },
}
</script>

<style lang="scss">
@import "../assets/css/base.css";

.myorder {
    background-color: #f1f1f1;
    height: 100vh;
}

.nav_bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    z-index: 999;
    background-color: #fff;
    border-bottom: 1px solid #eaeaea;


    .topTitle {
        height: 47px;
        background-color: #f6f6f6;
        display: flex;
        padding: 0 15px 0 15px;

        p {
            height: 47px;
            line-height: 47px;
            color: #1f2023;
            font-size: 16px;
            flex: 1;
            text-align: center;

        }

        .pric {
            width: 37px;
            background: url(../assets/img/left.png) no-repeat center center;
            background-size: 25%;
        }

        .pric:last-child {
            width: 37px;
            background: url(../assets/img/switch-ico.png) no-repeat center center;
            background-size: 50%;
        }
    }

    .tab_bar {
        height: 42px;
        background-color: #ffffff;

        ul {
            height: 42px;
            display: flex;

            li {
                width: 25%;
                height: 100%;
                line-height: 42px;
                text-align: center;
                color: #1c1508;
                font-size: 15px;

                &.con {
                    color: #ff6801;
                    border-bottom: 2px solid #fabe96;
                }
            }
        }
    }
}

.tables {
    padding-top: 111px;

    p {
        height: 63px;
        width: 100%;
        display: flex;
        justify-content: center;

        img {
            height: 63px;
            width: 83px;
        }
    }

    .fonts {
        padding-top: 12px;
        text-align: center;
        clear: #6c6962;
        font-size: 15px;
    }
}

.niuma {
    height: 100px;
}

.payment {
    height: 187px;
    margin-top: 10px;
    background-color: #fff;

    .shopname {
        height: 48px;
        line-height: 48px;
        font-size: 14px;
        color: #232222;
        font-weight: 700;
        padding-left: 15px;
    }

    .shopImg {
        padding-left: 15px;
        border-bottom: 2px solid #efefef;
        display: flex;

        .img {
            width: 75px;
            height: 75px;
            position: relative;

            .pofont {
                width: 100%;
                background-color: #000000;
                color: #f9fdff;
                font-size: 11px;
                text-align: center;
                position: absolute;
                bottom: 0px;
                left: 0;
                right: 0;
                margin: auto;
            }
        }

        .rightFont {
            width: 270px;
            height: 75px;
            padding-top: 6px;
            padding-left: 10px;
            background-color: #fafafa;

            .title1 {
                height: 20px;
                line-height: 20px;
                font-size: 13px;
                color: #484848;
            }
        }
    }

    .yesCar {
        width: 77px;
        height: 32px;
        border-radius: 8px;
        line-height: 32px;
        border: 2px solid #ffa265;
        box-shadow: 0 0 10px #ffe2cf;
        float: right;
        margin-top: 10px;
        margin-right: 10px;
        color: #ff6c18;
        font-size: 13px;
        text-align: center;
    }
}
</style>